package com.example.menuvirtualclient.rule;

import java.util.List;

import android.content.Context;

import com.example.menuvirtualclient.core.*;
import com.example.menuvirtualclient.data.ISession;
import com.example.menuvirtualclient.data.SessionFactory;
import com.example.menuvirtualclient.repository.DishMenuRepository;

public class DishMenuRule {

	private ISession _session;
	private final DishMenuRepository _repository;

	public DishMenuRule(Context context) {
		_session = SessionFactory.GetSession(context);
		_repository = new DishMenuRepository(context);
	}
	
	public boolean exist(DishMenu entity) throws Exception {
		try {
			_session.Open();
			return _repository.exist(entity);
		} 
		catch (Exception ex) {
			throw ex;
		}
		finally{
			_session.Close();
		}
	}
	
	public void Insert(DishMenu entity) throws Exception {
		try {
			_session.Open();
			_repository.Insert(entity);
		} 
		catch (Exception ex) {
			throw ex;
		}
		finally{
			_session.Close();
		}
	}
	
	public void deleteAll() throws Exception {
		try {
			_session.Open();
			_repository.Delete();
		} 
		catch (Exception ex) {
			throw ex;
		}
		finally{
			_session.Close();
		}
	}
	
}
